home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT41.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.2 KB  |  55 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                    
  4.                              Demonstration Program 41                        
  5.                                                                              
  6.   Demonstrates wgettextwidth and wgettextheight functions.                   
  7.                                                                              
  8.   *** PROJECT ***                                                           
  9.   This program requires the file WGT5_WC.LIB to be linked.                  
  10.                                                                          
  11.   *** DATA FILES ***                                                          
  12.   LITTLE.WFN and MEDIUM.WFN must be in your executable directory.
  13.                                                            WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <wgt5.h>
  18.  
  19. wgtfont medium;
  20. wgtfont little;
  21. char message[] = "This is the test string";
  22.  
  23. void main (void)
  24. {
  25.   printf ("WGT Example #41\n\n");
  26.   printf ("Various fonts are measured using WGETTEXTWIDTH and WGETTEXTHEIGHT.\n");
  27.   printf ("A keypress ends the program after sizes are reported.\n");
  28.   printf ("\n\nPress any key to continue.\n");
  29.   getch ();
  30.  
  31.   vga256 ();
  32.  
  33.   medium = wloadfont ("medium.wfn");
  34.   little = wloadfont ("little.wfn");
  35.  
  36.   wtextcolor (15);
  37.  
  38.   wgtprintf (0, 0, NULL, "%s", message);
  39.   wgtprintf (0, 8, NULL, "String width : %i pixels", wgettextwidth (message, NULL));
  40.   wgtprintf (0, 16, NULL, "String height: %i pixels", wgettextheight (message, NULL));
  41.  
  42.   wgtprintf (0, 50, medium, "%s", message);
  43.   wgtprintf (0, 66, NULL, "String width : %i pixels", wgettextwidth (message, medium));
  44.   wgtprintf (0, 74, NULL, "String height: %i pixels", wgettextheight (message, medium));
  45.  
  46.   wgtprintf (0, 100, little, "%s", message);
  47.   wgtprintf (0, 116, NULL, "String width : %i pixels", wgettextwidth (message, little));
  48.   wgtprintf (0, 124, NULL, "String height: %i pixels", wgettextheight (message, little));
  49.  
  50.   getch ();
  51.   wsetmode (3);
  52.   wfreefont (little);
  53.   wfreefont (medium);
  54. }
  55.